let eventUtils = {
  eventMessageMap:new Map(),
  //订阅消息
  subscribeMessage:function(eventName,cb){
      let {eventMessageMap} = this;
      let callBackList = eventMessageMap.get(eventName)?eventMessageMap.get(eventName):[];
      callBackList.push(cb);
      eventMessageMap.set(eventName,callBackList);
  },
  //发布消息
  publishMessage:function(eventName,...arg){
      let {eventMessageMap} = this;
      let callBackList = eventMessageMap.get(eventName)?eventMessageMap.get(eventName):[];
      callBackList.forEach(cb => {
          cb?cb(...arg):"";
      });
  },
  //混合入目标对象
  mixins:function(target){
      if(!target){
          return null;
      }

      for(let key in this){
          target[key] = this[key]
      }

      return target;
  }
}


export default eventUtils;